#!/bin/bash
###
 # @Author: lineCode 1145938682@qq.com
 # @Date: 2025-04-17 16:18:53
 # @LastEditors: lineCode 1145938682@qq.com
 # @LastEditTime: 2025-04-17 16:19:00
 # @FilePath: /backend/bulidEnv.sh
### 
# 生成时间戳
export TIMESTAMP=$(date +%Y%m%d-%H%M%S)
export TAG_SUFFIX=$(git rev-parse --short HEAD)
export TAG=${TIMESTAMP}-${TAG_SUFFIX}

# 参数校验
if [ $# -eq 0 ]; then
  echo "请通过参数指定文件目录"
  exit 1
fi

ENV_DIR=$1

# 写入 .env 文件
cat > ${ENV_DIR}/.env << EOF
TIMESTAMP=${TIMESTAMP}
TAG_SUFFIX=${TAG_SUFFIX}
TAG=${TAG}
EOF
